#ifndef __LOG_H__
#define __LOG_H__

#ifdef __cplusplus
extern "C" {
#endif

#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <syslog.h>

#define App_Ver 10001
#define IsReleaseVer 0
#if IsReleaseVer
#define EnableTerminalLog 0
#else
#define EnableTerminalLog 1
#endif

void hexData_printf(uint8_t* data, int len, bool isHex);
void terminal_printf(uint8_t level, const char* tag, const char* fmt, ...);

#define log_printf(level, tag, fmt, ...)                                                                               \
    do {                                                                                                               \
        terminal_printf(level, tag, fmt, ##__VA_ARGS__);                                                               \
    } while (0)

#define LOG_E(tag, fmt, ...) log_printf(LOG_ERR, tag, fmt, ##__VA_ARGS__)
#define LOG_W(tag, fmt, ...) log_printf(LOG_WARNING, tag, fmt, ##__VA_ARGS__)
#define LOG_I(tag, fmt, ...) log_printf(LOG_INFO, tag, fmt, ##__VA_ARGS__)
#define LOG_D(data, len, isHex) hexData_printf(data, len, isHex)

#ifdef __cplusplus
}
#endif

#endif    // __LOG_H__
